package com.ssm.spring;

import com.ssm.dao.UserMapper;
import com.ssm.entity.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;


//目标：测试一下spring的bean的某些功能
//junit整合spring的测试

//目标：测试一下spring的bean的某些功能
//junit整合spring的测试
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:test/applicationContext-dao.xml")
public class TestSpringUserMapper {

    @Autowired
    private UserMapper userMapper;

    @Test
    public void testQueryUserById(){
        User user = this.userMapper.queryUserById(1);
        System.out.println(user);
    }
    @Test
    public void testQueryAllUser(){
        List<User> users = this.userMapper.findAllUser();
        System.out.println(users.toString());
    }

    @Test
    public void testInsertUser(){
        User user = new User();
        user.setMoney(1000d);
        user.setName("马云");
        this.userMapper.insertUser(user);
        System.out.println(user.getId());
    }

}
